package com.iamgod.savemoney.base;

import com.iamgod.savemoney.sys.Config;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 数据库操作基类，负责数据库的建立、更新及其他公用功能
 * @author llj
 *
 */
public class BaseDao extends SQLiteOpenHelper {

	private static final int VERSION = 1;

	public BaseDao(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	public BaseDao(Context context, String name, int version) {
		this(context, name, null, version);
	}

	public BaseDao(Context context, String name) {
		this(context, name, VERSION);
	}

	// 该函数是在第一次创建的时候执行，实际上是第一次得到SQLiteDatabase对象的时候才会调用这个方法
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		System.out.println("create a database");
		// execSQL用于执行SQL语句
		db.execSQL(Config.DataBase.Create_Table_PlanConfig);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		System.out.println("upgrade a database");
	}

}
